/**
 * Created by Administrator on 2017/5/17.
 */

$(function(){
    index5();
});
var index010secInterval;
var inter1;
function index5(){
    getToiletSeat();
    getToiletStatus();
    //checkEmptycw();
    clearInterval(index010secInterval);
    clearInterval(inter1);
    index010secInterval = setInterval(getToiletSeat,120000);
    inter1 = setInterval(getToiletStatus,120000);
}
//查询厕所坑位状态
function getToiletSeat(){
    $.get(baseURL + "gc/statoiletseat/getToiletSeat", function(r){
        $('.right').attr("src","../../statics/css/img/right_green.png")
        $('.left').attr("src","../../statics/css/img/left_green.png")
        var southMaleUsed=0;
        var southFemaleUsed=0;
        var northMaleUsed=0;
        var northFemaleUsed=0;
        var southMale=r.data.southMale;
        var southFemale=r.data.southFemale;
        var northMale=r.data.northMale;
        var northFemale=r.data.northFemale;
        for (var key in southMale){
            //console.log(key+ "----"+southMale[key])
            if(southMale[key]==1){
                southMaleUsed++;
                var className = $('#s'+key).className;
                if(className=='right'){
                    $('#s'+key).attr("src","../../statics/css/img/right_red.png")
                }else {
                    $('#s'+key).attr("src","../../statics/css/img/left_red.png")
                }
            }
        }
        for (var key in southFemale){
            //console.log(key+ "----"+southFemale[key])
            if(southFemale[key]==1){
                southFemaleUsed++;
                var className = $('#s'+key).className;
                if(className=='right'){
                    $('#s'+key).attr("src","../../statics/css/img/right_red.png")
                }else {
                    $('#s'+key).attr("src","../../statics/css/img/left_red.png")
                }
            }
        }
        for (var key in northMale){
            console.log(key+ "----"+northMale[key])
            if(northMale[key]==1){
                northMaleUsed++;
                var className = $('#n'+key).className;
                if(className=='right'){
                    $('#n'+key).attr("src","../../statics/css/img/right_red.png")
                }else {
                    $('#n'+key).attr("src","../../statics/css/img/left_red.png")
                }
            }
        }
        for (var key in northFemale){
            console.log(key+ "----"+northFemale[key])
            if(northFemale[key]==1){
                northFemaleUsed++;
                var className = $('#n'+key).className;
                if(className=='right'){
                    $('#n'+key).attr("src","../../statics/css/img/right_red.png")
                }else {
                    $('#n'+key).attr("src","../../statics/css/img/left_red.png")
                }
            }
        }
        $("#manuses").text(southMaleUsed);
        $("#manunuses").text(19-southMaleUsed);
        $("#womanuses").text(southFemaleUsed);
        $("#womanunuses").text(48-southFemaleUsed);

        $("#manusen").text(northMaleUsed);
        $("#manunusen").text(19-northMaleUsed);
        $("#womanusen").text(northFemaleUsed);
        $("#womanunusen").text(48-northFemaleUsed);
    });
}

function getToiletStatus(){
    $.get(baseURL + "gc/statoiletstatus/getToiletStatus", function(r){
        //南区男厕001
        //南区女厕002
        //北区男厕003
        //北区女厕004
        for (var key in r.data){
            if(key=="001"){
              $("#rllmans").text(r.data[key].visitors+"人/次");
              $("#tempmans").text(r.data[key].temperature+"℃");
              $("#hummans").text(r.data[key].humidity+"%");
              $("#smellmans").text(r.data[key].odorconcentration+"ppm");
            }else if(key=="002"){
                $("#rllwomans").text(r.data[key].visitors+"人/次");
                $("#tempwomans").text(r.data[key].temperature+"℃");
                $("#humwomans").text(r.data[key].humidity+"%");
                $("#smellwomans").text(r.data[key].odorconcentration+"ppm");
            }else if(key=="003"){
                $("#rllmann").text(r.data[key].visitors+"人/次");
                $("#tempmann").text(r.data[key].temperature+"℃");
                $("#hummann").text(r.data[key].humidity+"%");
                $("#smellmann").text(r.data[key].odorconcentration+"ppm");
            }else if(key=="004"){
                $("#rllwomann").text(r.data[key].visitors+"人/次");
                $("#tempwomann").text(r.data[key].temperature+"℃");
                $("#humwomann").text(r.data[key].humidity+"%");
                $("#smellwomann").text(r.data[key].odorconcentration+"ppm");
            }
        }
    })
}

